import 'package:flutter/material.dart';
import 'package:hospitable_rental/pages/home/home/home_recommend_item.dart';
import 'package:hospitable_rental/pages/home/home/home_recommend_item_widget.dart';
import 'package:hospitable_rental/routes/routes.dart';

class HomeRecommend extends StatelessWidget {
  final List<HomeRecommendItem> dataList;

  const HomeRecommend({
    Key? key,
    this.dataList = recommendItemList,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(10.0),
      decoration: BoxDecoration(color: Color(0x08000000)),
      child: Column(
        children: [
          GestureDetector(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "房屋推荐",
                  style: TextStyle(
                    color: Colors.black,
                    fontWeight: FontWeight.w600,
                  ),
                ),
                Text(
                  "更多 >",
                  style: TextStyle(color: Colors.black45),
                ),
              ],
            ),
            onTap: () => Navigator.of(context).pushNamed(Routes.login),
          ),
          SizedBox(height: 10.0),
          Wrap(
            spacing: 10.0, // 主轴（水平）方向间距
            runSpacing: 10.0, // 纵轴（垂直）方向间距
            alignment: WrapAlignment.center, // 沿主轴方向居中
            children: dataList
                .map(
                  (item) => HomeRecommendItemWidget(item),
                )
                .toList(),
          ),
        ],
      ),
    );
  }
}
